<?php
class TaskAction extends HomeAction{
    //新闻列表
    public function show(){
		$this->display('task_show');
    }
	//新闻内容
    public function jsondata(){
		$vid=$_GET['id'];
		$pid=$_GET['p']?intval($_GET['p']):1;
		$rs=D("task");
		
		$arr=$rs->where()->limit(20)->page($page)->select();

		echo json_encode(array('rows'=>$arr,'total'=>$rs->where()->limit(20)->page($page)->count(),'error'=>null));
		return;
    }
    public function edit(){
		$this->display('task_show');
    }

	public function insert(){
		header("Content-Type:text/html; charset=utf-8");
		$Form=M("task");

		$result = $Form -> add($_POST);
		
		Log::write('调试的SQL：'.$_POST['name'], Log::SQL);
		echo "success";
	
		return;
	}
	public function update(){
		$id=$_GET['id'];
		$id = 6;
		$where['taskid']=$id;
		if($id){
			$data['name'] = "WJ咖啡馆";
		    $rs=D("Task");
		    $arr=$rs->where($where)->save($data);
			echo $rs->getLastSql();
		}
	}
	public function delete(){
		$id=$_GET['id'];
		if($id){
		    $rs=D("Task");			
		    $arr=$rs->delete($where['id']=$id);
		}
    }
}
?>